#include <Keypad.h>

const byte ROWS = 4;  //行
const byte COLS = 4;  //列

char hexaKeys[ROWS][COLS] = {
  { '1', '2', '3', 'U' },
  { 'L', '6', '5', '4' },
  { 'R', '9', '8', '7' },
  { 'D', 'B', 'A', '0' }
};
byte rowPins[ROWS] = { 6, 7, 8, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
  //检测
  while(true) {
    if (Serial.available()) {           
      Serial.println("keyboard");
      break;
    }
  }
}

void loop() {
  char customKey = customKeypad.getKey();
  if (customKey) {
    Serial.print(customKey);
  }
}
